package cn.iocoder.yudao.module.member.dal.mysql.praxisProject;

import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.member.controller.admin.praxisProject.vo.*;
import cn.iocoder.yudao.module.member.dal.dataobject.praxisProject.PraxisProjectDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * 实践项目 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface PraxisProjectMapper extends BaseMapperX<PraxisProjectDO> {

    List<PraxisProjectRespVO> getPraxisProjectList(IPage page, @Param("params") Map<String, Object> params);

    List<PraxisProjectRespVO> getPraxisProjectListByTitle(@Param("title") String title,@Param("queryType") Integer queryType);

    PraxisProjectRespVO getPraxisProjectInfoById(  @Param("id") Long id,@Param("scheduleType") Integer scheduleType);

    PraxisProjectRespVO getProjectInfoById(  @Param("id") Long id );

    void revertPraxisProject(@Param("id") Long id);

    default List<PraxisProjectDO> selectList(PraxisProjectExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<PraxisProjectDO>()
                .eqIfPresent(PraxisProjectDO::getTitle, reqVO.getTitle())
                .eqIfPresent(PraxisProjectDO::getProjectTypeId, reqVO.getProjectTypeId())
                .eqIfPresent(PraxisProjectDO::getHoldUnitUrl, reqVO.getHoldUnitUrl())
                .likeIfPresent(PraxisProjectDO::getHoldUnitName, reqVO.getHoldUnitName())
                .eqIfPresent(PraxisProjectDO::getProjectDescription, reqVO.getProjectDescription())
                .eqIfPresent(PraxisProjectDO::getEntryType, reqVO.getEntryType())
                .eqIfPresent(PraxisProjectDO::getItemPeopleNum, reqVO.getItemPeopleNum())
                .eqIfPresent(PraxisProjectDO::getEntryInformation, reqVO.getEntryInformation())
                .eqIfPresent(PraxisProjectDO::getCompetitionRules, reqVO.getCompetitionRules())
                .eqIfPresent(PraxisProjectDO::getReviewRules, reqVO.getReviewRules())
                .eqIfPresent(PraxisProjectDO::getReviewRequire, reqVO.getReviewRequire())
                .eqIfPresent(PraxisProjectDO::getEntryRequire, reqVO.getEntryRequire())
                .eqIfPresent(PraxisProjectDO::getProjectRewards, reqVO.getProjectRewards())
                .eqIfPresent(PraxisProjectDO::getVideoUrl, reqVO.getVideoUrl())
                .eqIfPresent(PraxisProjectDO::getCompetitionOrganization, reqVO.getCompetitionOrganization())
                .eqIfPresent(PraxisProjectDO::getAnnexDownType, reqVO.getAnnexDownType())
                .eqIfPresent(PraxisProjectDO::getStatus, reqVO.getStatus())
                .eqIfPresent(PraxisProjectDO::getWeight, reqVO.getWeight())
                .betweenIfPresent(PraxisProjectDO::getReleaseTime, reqVO.getBeginReleaseTime(), reqVO.getEndReleaseTime())
                .eqIfPresent(PraxisProjectDO::getExamineFlag, reqVO.getExamineFlag())
                .eqIfPresent(PraxisProjectDO::getExamineStatus, reqVO.getExamineStatus())
                .eqIfPresent(PraxisProjectDO::getExamineNotes, reqVO.getExamineNotes())
                .betweenIfPresent(PraxisProjectDO::getExamineTime, reqVO.getBeginExamineTime(), reqVO.getEndExamineTime())
                .betweenIfPresent(PraxisProjectDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(PraxisProjectDO::getId));
    }

    void updatePraxisProjectById(@Param("praxisProjectDO") PraxisProjectDO praxisProjectDO);

    List<PraxisAnnexVO> getPraxisAnnexListByProjectId(@Param("relationId") Long relationId,@Param("relationType") Integer relationType);

    List<PraxisProjectScheduleVO> getScheduleListByProjectId(@Param("projectId") Long projectId);

    void saveProjectRecord(@Param("record") PraxisProjectRecordVO record);

    PraxisProjectScheduleVO getNextScheduleByProjectId(@Param("projectId") Long projectId,@Param("scheduleType") Integer scheduleType);

    @TenantIgnore
    Integer getMaxWeight(@Param("projectTypeId") Long projectTypeId);

    @TenantIgnore
    Integer getScheduleType(@Param("id") Long id);

    void updateViewNum(@Param("id") Long id);
    /**
     * 获得实践项目记录列表
     *
     * @param projectId 编号
     * @return 实践项目记录列表
     */
    List<PraxisProjectRecordVO> getPraxisProjectRecordList( @Param("projectId") Long projectId);

    List<PraxisFeedBackVO> getFeedBackPageByProjectId(IPage page, @Param("params") Map<String, Object> params);

    Integer getProjectCountByTitle(@Param("title") String title,@Param("id")  Long id);

    void savePraxisViewDetail(@Param("id")  Long id,@Param("userId") Long userId,@Param("viewMonth") String viewMonth);

    PraxisProjectCountVO getPraxisProjectCount(@Param("id") Long id);

    List<PraxisProjectViewCountVO> getPraxisProjectViewCount(@Param("id") Long id,@Param("list") List<String> list);

    List<PraxisProjectViewCountVO> getPraxisProjectMajorCount(@Param("id") Long id );

    List<String> getPraxisProjectBriskCount();
}
